package com.xzit.rcpyxt.controller;

import com.xzit.rcpyxt.constant.MessageCode;
import com.xzit.rcpyxt.dto.*;
import com.xzit.rcpyxt.entity.SignIn;
import com.xzit.rcpyxt.service.SignInService;
import com.xzit.rcpyxt.service.StudentService;
import com.xzit.rcpyxt.utils.PageUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/student")
public class StudentController {

    @Autowired
    private StudentService studentService;
    @Autowired
    private SignInService signInService;

    @ApiOperation(value = "学生绑定列表")
    @RequestMapping(value = "/findByStudentList", method = RequestMethod.GET)
    public ResultModel findByStudentList(StudentBindRequest studentDto) {
        PageUtil byClassList = studentService.findByStudentList(studentDto);
        return new ResultModel(MessageCode.OK, byClassList);
    }

    @ApiOperation(value = "获取指定班级学生信息列表")
    @RequestMapping(value = "/findClassUserList", method = RequestMethod.GET)
    public ResultModel findClassUserList(ClassUserListRequest studentDto) {
        PageUtil byClassList = studentService.findByTeacherList(studentDto);
        return new ResultModel(MessageCode.OK, byClassList);
    }

    @ApiOperation(value = "学生签到")
    @RequestMapping(value = "/signIn", method = RequestMethod.POST)
    public ResultModel signIn(@RequestBody SignIn signIn) {
        signInService.signIn(signIn);
        return new ResultModel(MessageCode.OK);
    }

}
